Loading...

Социалната мрежа на България

Блог

Резултати от търсене по таг: "fast fourier transformation"

Software solution by BnTech


http://bntech.info/


The following post demonstrates the use of MathTBox library within Visual Basic for .NET environment.
The example that we are going to explore shows how to make a fast fourier transform of a time signal. The time signal can be any form of analog signal - for example audio, speech etc. In our case we are going to simulate it for simplicity.
Open ...The following post demonstrates the use of MathTBox library within Visual Basic for .NET environment.
The example that we are going to explore shows how to make a fast fourier transform of a time signal. The time signal can be any form of analog signal - for example audio, speech etc. In our case we are going to simulate it for simplicity.
Open up Visual Studio and create a new windows forms for VB.net project.

Type in a name for the project and save the project in a dedicated folder on your drive. 
In design view add two chart controls on the form and a button.
AddChart.PNG     
Arrange the charts so that they are wide as the form and place them one below the other.Change the Text property of the button to :"Calculate FFT"  and double click the button.
We have to import the Library and its DLL to the project - go to Project->add reference
In the resulting window choose browse and navigate to the directory where you store  MathToolBox.dll and select it.
copy libfftw3-3.dll, libfftw3f-3.dll and libfftw3-3l.dll  from the MathTbox folder to the bin/debug folder of the solution. ( The startup folder )
add the following to the top of the Form code - above the main class definition:

Imports MathToolBox'Public Class Form1
.......Finally declare a variable of the imported class:
Public MTB As MathTBox Within the Button1_Click subroutine we are going to do the signal simulation, FFT calculation and
visualisation of the signal and the fft result on the chart controls.The first task we have to do is generate a time signal. We are going to use the formula
from the manual, which you can download here:
y = 2.5 · sin (2π · 50 · t) + 1.2 · cos (2π · 100 · t) + 3.0 · sin (2π · 150 · t) + 1.5
With the help of this formula we are able to calculate , for every X the value of Y. The resulting signal will have 3 component frequencies (50Hz,100Hz,150Hz) and a positive offset.Before we continue we have to make some explanations on measuring signals and values from the real - physical world
to a form the computer understands.
The way we pass information to the computer is by means of digitizers. These devices translate the values of different real life processes
into discrete set of points. One major characteristic of a digitizer is the speed with which it builds the set of points, this is also called
Sampling speed. In essence The sampling speed shows how many points can a digitizer acquire per second.Returning back to our code, in order to calculate Y values we have to know our X values, which represent the time at which the given sample was taken.
We will simulate a digitizer with a 1Khz sampling speed. This will give us 1ms interval between each sample point and we will start at time 0.we first declare array to hold 1000 samples, which with a 1Khz Sampling speed gives us 1 second of signal.

Dim elements(1000) As Double
We declare a variable to hold the time (X value ) and we start from zero.
Dim t As Double = 0we generate our time series with a time between elements = 0.001        For i = 0 To elements.Length - 1
elements(i) = 2.5 * Math.Sin(Math.PI * 2 * 50 * t) _
+ 1.2 * Math.Cos(Math.PI * 2 * 100 * t) _
+ 3 * Math.Sin(2 * Math.PI * 150 * t) + 1.5
'increment t for the next element
t += 0.001 ' 1 ms increments        NextWe can now plot the generated signal to the first chart:For i = 0 To elements.Length - 1            Chart1.Series(0).Points.AddXY((i * 0.001), elements(i))
NextIn order to have the fft we have to instantiate the MTB variable.MTB = New MathTBoxand to declare  a new variable of type FFTResult to hold the result of the fft() routine. This type can be found within MathToolBox namespace.
A detailed explanation of the type can be found in the manual.Dim result As MathToolBox.FFTResult = MTB.FFT(elements, 0.001)Here we assign the result variable values from the FFT() function contained in the MathToolBox  namespace. The parameters passed to the function are the array elements which is holding the points we generated, and the time in seconds between two consecutive points. This value is equal to 1 second divided by  Sampling speed - 1/1000 in our case.That's it we are done. now we can plot the FFT in the second chart:For i = 0 To result.Frequencies.Length - 1
Chart2.Series(0).Points.AddXY(result.Frequencies(i), result.Amplitudes(i))        NextHere is how the entire code should look:Imports MathToolBoxPublic Class Form1
    Public MTB As MathTBox    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'y = 2.5 · sin (2π · 50 · t) + 1.2 · cos (2π · 100 · t) + 3.0 · sin (2π · 150 · t) + 1.5
    Dim elements(1000) As Double
    Dim t As Double = 0
    'First we generate our time series with a time between elements = 0.001
     For i = 0 To elements.Length - 1
           elements(i) = 2.5 * Math.Sin(Math.PI * 2 * 50 * t) _
                 + 1.2 * Math.Cos(Math.PI * 2 * 100 * t) _
                 + 3 * Math.Sin(2 * Math.PI * 150 * t) + 1.5
           'increment t for the next element
      t += 0.001      Next       For i = 0 To elements.Length - 1            Chart1.Series(0).Points.AddXY((i * 0.001), elements(i))      Next
      'instantiate mtb
      MTB = New MathTBox
      'declare a variable to hold the result of the fft transform
       Dim result As MathToolBox.FFTResult = MTB.FFT(elements, 0.001)       ' draw the result on the chart
       For i = 0 To result.Frequencies.Length - 1
              Chart2.Series(0).Points.AddXY(result.Frequencies(i), result.Amplitudes(i))         Next
    End SubEnd Classand here is how the program looks:

http://bntech.info/

Ani Юни 25 '15 · Коментари: 2 · Тагове: fft, fast fourier transformation, fourier transformation, fft2, mathtbox library for .net, bntech

Търсене по таг

#sad gsm сервиз ip камери iphone iphone втора употреба pvc врати pvc дограма seo автомобили автомобили под наем авточасти агенция за преводи алуминиева дограма английски език астма бабини зъби баня бебешки колички бебешки колички бижута билков екстракт билкови добавки билкови секс стимуланти билкови хранителни добавки болка брачни халки български билки български добавки български трибулус бърз кредит бързи кредити венецианска мазилка видеонаблюдение водопроводчик врати входни врати въздушен компресор външни ролетни щори градина гражданска отговорност грижа за кожата дамски парфюми детокс чай детски лагери диабет димитър белелиев добавки добавки за бързо покачване на мускулна маса добавки за енергия добавки за енергия и издръжливост добавки за енергия и сила дограма доставка на цветя дрехи екскурзия екстракт от трибулус екстремни спортове еленов корен жени заеми залози застраховки здраве здравословен хляб зъболекар извънгабаритни товари изработка на сайт имоти интериорни врати камери каяк в гърция каякинг килими климатици козметика кола под наем коледни аранжировки коледни подаръци коли коли под наем колички комарници компресор компресори коректна фирма кошници с цветя красота кредит до заплата кредити кредити до заплата кредити за пенсионери крепежни елементи кръвна захар лазерен център лазерна епилация левзея легализация на документи лъжа любов магазин магазин за мебели магазини мазилки мебели международен транспорт мобилни телефони мода мускулна маса добавки надежда наргиле никотинамид рибозид обзавеждане за баня обич обувки онлайн онлайн игри онлайн кредит онлайн магазин оптимизация отслабване оферти парфюм парфюми пвц дограма писмени преводи плочки за баня подарък подаръци подхранване на пчели почивка преводаческа агенция преводи превоз на товари предателство протеинов хляб протектори за телефони пълнозърнест хляб пясъчна мазилка работа в чужбина рак рафтинг рафтинг по струма реклама ремонт рент а кар рози ролетни щори свредла за бетон селски бял хляб селски пълнозърнест хляб сертификат коректна фирма сила ски ски училище смарт часовници софия спешни кредити спешни пари спомен спомени спорт сребърни бижута сребърни гривни сребърни колиета сребърни обеци сребърни пръстени сребърни синджири стоматолог стъклопакет сувенири суперхрани счетоводство сълзи сърце телефони телефони втора употреба тениска с щампа тениски тиймбилдинг той топене на мазнини топлоизолация траурна агенция трибулус услуги услуги софия фитнес добавки хамалски услуги хипогликемия хляб хляб с лимец хранителни добавки хранителни добавки за мускулна маса цветя чай детокс чай за детоксикация чай за отслабване часовници щастие щори